#include<iostream>
#include<deque>
using namespace std;
const int N = 2000005;
int a[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	deque<int> q;

	for (int i = 0;i < n;i++)
	{
		while (!q.empty() && q.front() < i - k + 1)
		{
			q.pop_front();
		}

		while (!q.empty() && a[q.back()] <= a[i])
		{
			q.pop_back();
		}
		q.push_back(i);

		 if (i >= k - 1) 
		 {
            cout << a[q.front()] << endl;
        }
	}

	return 0;
}
